public class SoldState implements State
{
	GumballMachine machine;

	public SoldState(GumballMachine in)
	{
		machine = in;
	}

	public void insertQuarter()
	{
		System.out.println("Please wait.");
	}

	public void ejectQuarter()
	{
		System.out.println("No quarter left.");
	}

	public void turnCrank()
	{
		System.out.println("Run once");
	}

	public void dispense()
	{
		machine.releaseBall();
		if(machine.getCount() > 0)
		{
			machine.setState(machine.getNoQuarterState());
		}
		else
		{
			System.out.println("Out of Gum Balls.");
			machine.setState(machine.getSoldOutState());
		}
	}

}

